var CardGrid = {
	grid:function(option,id){
		var boss = this;
		boss.option = option;
		option.tableClass = "widgets_card_grid_table_list";
		option.HeadRender = boss.HeadRender;
		option.trClass = "widgets_card_grid_table_tr";
		option.RowRender = boss.RowRender;
		option.FootRender = boss.FootRender;
		option.ftClass = "widget_grid_table_foot_page_button";
		var grid = $("#"+id).WidgetGrid(option);
		return grid;
	},
	HeadRender:function(Cloumns,Checkbox){
		return null;
	},
	RowRender:function(data,i){
		var boss = this;
		var columns = boss.Cloumns;
		var img = data[columns.img];
		var title = data[columns.title];
		var row1 = columns.row1;
		var row2 = columns.row2;
		var row3 = columns.row3;
		var todo = data[columns.todo];
		var tdClass = "";
		
		if((i%2) == 0)
		{
			tdClass = "widgets_grid_table_td_odd";
		}
		else
		{
			tdClass = "widgets_grid_table_td_even";
		}
		
		var tr = '<tr class="widgets_card_grid_table_tr">';
		
		tr += '<td class="widgets_card_grid_table_td widgets_card_grid_table_td_img '+tdClass+'"><div>';
		if(img != null && img != ""){
			if(img.indexOf("http") == 0){
				tr += '<img src="' + img + '"/>';
			}else if(img.indexOf("http") == -1){
				tr += '<img src="' + imageBurl + "/" + img + '"/>';
			}
		}
		
		tr += "</div></td>";
		
		tr += '<td class="widgets_card_grid_table_td widgets_card_grid_table_td_content '+tdClass+'">';
		tr += '<div class="widgets_card_grid_table_td_title">'+title+'</div>';
		
		tr += CardGrid.getRowHtml(row1,data);
		tr += CardGrid.getRowHtml(row2,data);
		tr += CardGrid.getRowHtml(row3,data);
		
		tr += '</td>';
			
		tr += '<td class="widgets_card_grid_table_td widgets_card_grid_table_td_todo '+tdClass+'">';
		tr += todo;
		tr += '</td>';
		tr += '</tr>';
		return tr;
	},
	getRowHtml:function(row,data){
		var html = "";
		if(row != null ){
			html += '<div class="widgets_card_grid_table_td_tip">';
			for(var i=0;i<row.length;i++){
				var columnInfo = row[i].split(",");
				var columnName = columnInfo[0];
				var columnTxt = null;
				if(columnInfo.length > 1){
					columnTxt = columnInfo[1];
				}
				var value = data[columnName];
				if(value != null && value != ""){
					if(columnTxt != null && columnTxt != ""){
						html += '<span>'+columnTxt+'：'+value+'</span><em>|</em>';
					}
					else{
						html += '<span>'+value+'</span><em>|</em>';
					}
					
				}
			}
			html += '</div>';
		}
		return html;
	},
	FootRender:function(PageIndex,PageCount,RecordCount,PageSize,Cloumns,Checkbox){
		var colspan = 3;
		
		var gridFootContent = "<tr class='tableHead'>";
		gridFootContent+='<th class="ftclass" colspan="'+colspan+'">';
		gridFootContent+='<div class="widget_grid_table_foot_page_button">';
		gridFootContent+='<a style="" href="First">首页</a>&nbsp;&nbsp;';
		gridFootContent+='<a href="Prev">上页</a>&nbsp;&nbsp;';
		gridFootContent+='<a href="Next">下页</a>&nbsp;&nbsp;';
		gridFootContent+='<a href="Last">尾页</a>&nbsp;';
		gridFootContent+='</div><div class="widget_grid_table_foot_page_span">';
		gridFootContent+='<span >第'+PageIndex+'页/共'+PageCount+'页</span>&nbsp;|&nbsp;';
		gridFootContent+='<span>记录总数:'+RecordCount+'</span>&nbsp;|&nbsp;';
		gridFootContent+='<span>每页显示:</span>';
		gridFootContent+='<a >'+PageSize+'</a>';
		gridFootContent+='</div>';
		gridFootContent+='</th>	';
		gridFootContent+='</tr>';
		var gridFootTr = $(gridFootContent);
		return gridFootTr;
	},
	getTodoHtml: function(data){
		var boss = this;
		
		var todoContent = "<table class='widgets_card_grid_table_td_todo_table'>";
		for(var i = 0; i < data.length; i++){
			var row = data[i];
			todoContent += "<tr><td>" + row + "</td></tr>";
		}
		todoContent += "</table>";
		return todoContent;
	}
};